#include <iostream>
#include <unordered_map>
#include <vector>
#include <string>
#include <algorithm>

std::unordered_map<std::string, int> str_an_int = {
    {"one", 1},
    {"two", 2},
    {"three", 3},
    {"four", 4},
    {"five", 5},
    {"six", 6},
    {"seven", 7},
    {"eight", 8},
    {"nine", 9},
    {"zero", 0}
};

bool is_prime(int n) {
    if (n < 2) return false;
    if (n == 2) return true;
    if (n % 2 == 0) return false;
    for (int i = 3; i * i <= n; i += 2) {
        if (n % i == 0) return false;
    }
    return true;
}

int find_nearest_prime(int number) {
    if (number < 2) return 2;
    else if (number == 2) return 2;
    else if (number % 2 == 0) return find_nearest_prime(number + 1);
    else {
        for (int num = number + 1; num > 0; num -= 2) {
            if (is_prime(num)) return num;
        }
    }
    return -1;
}

std::pair<bool, std::string> str_to_int(const std::string& str_num) {
    std::vector<int> num_list;
    std::vector<std::string> splited_str;
    std::string temp = "";
    for (char c : str_num) {
        if (c == ' ') {
            splited_str.push_back(temp);
            temp = "";
        } else {
            temp += c;
        }
    }
    splited_str.push_back(temp);

    for (const std::string& i : splited_str) {
        if (str_an_int.find(i) == str_an_int.end()) {
            return {false, "Wrong input"};
        }
        num_list.push_back(str_an_int[i]);
    }

    std::string result = "";
    for (int i : num_list) {
        result += std::to_string(i);
    }
    return {true, result};
}

std::string main(const std::string& num) {
    std::pair<bool, std::string> status_num = str_to_int(num);
    if (status_num.first) {
        int n = std::stoi(status_num.second);
        int u = find_nearest_prime(n + 5);
        int m = find_nearest_prime(n);
        if (n - m > u - n) {
            return std::to_string(u);
        }
        return std::to_string(m);
    } else {
        return status_num.second;
    }
}

int main() {
    std::string input;
    std::getline(std::cin, input);
    std::cout << main(input) << std::endl;
    return 0;
}
